﻿@model HQPad.Models.Invocation

@{
    ViewBag.Title = "Edit: " + @Html.Raw(Model.Name);
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@section PageScripts {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}

<h1>Edit invocation: @Html.Raw(Model.Name)</h1>

<section class="content">

@using (Html.BeginForm()) {
    <fieldset class="block form form-wide-label">
        <legend>Basics</legend>

        @Html.ValidationSummary(true)

        @Html.HiddenFor(model => model.InvocationID)
        @Html.HiddenFor(model => model.RuleSetID)

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Name)
        </div>
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Family)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Family)
            @Html.ValidationMessageFor(model => model.Family)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.GroupName)
        </div>
            @Html.TextBoxFor(model => model.GroupName)
            @Html.ValidationMessageFor(model => model.GroupName)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.RequiredGroupName)
        </div>
            @Html.TextBoxFor(model => model.RequiredGroupName)
            @Html.ValidationMessageFor(model => model.RequiredGroupName)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Slug)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Slug, new { disabled = true })
            @Html.ValidationMessageFor(model => model.Slug)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Deleted)
        </div>
            @Html.EditorFor(model => model.Deleted)
            @Html.ValidationMessageFor(model => model.Deleted)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Description)
        </div>
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Rank)
        </div>
            @Html.DropDownList("Rank")
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Range)
        </div>
            @Html.EditorFor(model => model.Range)
            @Html.ValidationMessageFor(model => model.Range)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Duration)
        </div>
            @Html.EditorFor(model => model.Duration)
            @Html.ValidationMessageFor(model => model.Duration)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.IsExtendable)
        </div>
            @Html.EditorFor(model => model.IsExtendable)
            @Html.ValidationMessageFor(model => model.IsExtendable)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.IsCommon)
        </div>
            @Html.EditorFor(model => model.IsCommon)
            @Html.ValidationMessageFor(model => model.IsCommon)
        </div>

        <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Sphere)
        </div>
            @Html.DropDownList("Sphere")
            @Html.ValidationMessageFor(model => model.Sphere)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

@if (!Model.IsCommon)
{
    using (Html.BeginForm("AddGuild", "Invocation", new { slug = Model.Slug }))
    {
        <fieldset class="block form form-wide-label">
            <legend>Guilds</legend>
            @if (Model.Guilds == null || Model.Guilds.Count == 0)
            {
                <p>This invocation is not assigned to any guilds.</p>
            }
            else
            {
                <table>
                    <thead>
                        <tr>
                            <th>Guild</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach (HQPad.Models.Guild guild in Model.Guilds)
                    {
                        <tr>
                            <td>@Html.Raw(guild.Name)</td>
                            <td>@Html.ActionLink("Delete", "DeleteGuild", "Invocation", new { id = guild.GuildID }, null)</td>
                        </tr>
                    }
                    </tbody>
                </table>
            }

        <div class="field-item">
            <div class="label">Add invocation to guild:</div>
            @Html.DropDownList("Guilds")
        </div>

            <p>
                <input type="submit" value="Add guild" class="button" />
            </p>
        </fieldset>

    }
}

<div class="block">
    @Html.ActionLink("Back to List", "Index", null, new { @class = "button" })
</div>

</section>